package com.infra.micro.quartz.api;

import com.infra.micro.quartz.fallback.QuartzJobApiFallback;
import com.infra.micro.quartz.model.req.QueryQuartzJobReq;
import com.infra.micro.quartz.model.vo.QuartzJobVO;
import com.infra.common.resp.Page;
import com.infra.common.resp.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

@Component
@FeignClient(value = "micro-quartz-service", path = "/api/quartz/job", fallbackFactory = QuartzJobApiFallback.class)
public interface QuartzJobApi {

    @RequestMapping(value = "", method = RequestMethod.POST)
    Response<Boolean> create(@RequestBody QuartzJobVO model);

    @RequestMapping(value = "/{jobId}", method = RequestMethod.PUT)
    Response<Boolean> update(@PathVariable("jobId") Long jobId, @RequestBody QuartzJobVO model);

    @RequestMapping(value = "/{jobId}", method = RequestMethod.GET)
    Response<QuartzJobVO> queryById(@PathVariable("jobId") Long jobId);

    @RequestMapping(value = "/{jobId}", method = RequestMethod.DELETE)
    Response<Boolean> deleteById(@PathVariable("jobId") Long jobId);

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    Response<Page<QuartzJobVO>> queryListByPage(@SpringQueryMap QueryQuartzJobReq req);
}
